package cn.zswltech.gruul.web.api.controller;

import cn.zswltech.gruul.api.MyAppApi;
import cn.zswltech.gruul.common.dal.dao.YggdrasilAppMapper;
import cn.zswltech.gruul.common.entity.YggdrasilAppDO;
import cn.zswltech.gruul.common.result.Response;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.annotation.Resource;
import java.util.List;

/**
 * @author Jim
 * @version 1.0.0
 * @descripition:
 * @date 2024/1/31 12:10
 */
@RestController
public class YggdrasilAppController implements MyAppApi {

    @Resource
    private YggdrasilAppMapper appMapper;

    @Override
    public Response<List<YggdrasilAppDO>> myApp(){
        ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        String account = requestAttributes.getRequest().getHeader("test-account");
        List<YggdrasilAppDO> yggdrasilAppDOS = appMapper.selectAll();
        return Response.success(yggdrasilAppDOS);
    }
}
